package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.RedPacketRule;
import com.sc.nft.entity.vo.AdminRedPacketRuleFindPageVO;
import com.sc.nft.mapper.RedPacketRuleMapper;
import com.sc.nft.sup.PageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class RedPacketRuleDao extends ServiceImpl<RedPacketRuleMapper, RedPacketRule> {

    /**
     * 根据藏品id和操作类型,获取对象数据集合
     *
     * @param collectionId
     * @param type
     */
    public List<RedPacketRule> getByCollectionIdAndType(Long collectionId, Integer type) {
        QueryWrapper<RedPacketRule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("collection_id", collectionId);
        queryWrapper.eq("type", type);
        return baseMapper.selectList(queryWrapper);
    }

    public Integer overlapping(Long collectionId, Integer type,Integer min, Integer max) {
        return baseMapper.overlapping(collectionId,type,min,max);
    }

    public Integer overlappingUpdate(Long collectionId, Integer type,Integer min, Integer max,Long id) {
        return baseMapper.overlappingUpdate(collectionId,type,min,max,id);
    }

    public Page<AdminRedPacketRuleFindPageVO> findPage(PageRequest request) {
        return baseMapper.findPage(request.toMp());
    }

}
